package com.design3.graduatethesissys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.design3.graduatethesissys.common.utils.GetUserName;
import com.design3.graduatethesissys.domain.Subject;
import com.design3.graduatethesissys.mapper.StudentMapper;
import com.design3.graduatethesissys.mapper.SubjectMapper;
import com.design3.graduatethesissys.service.SubjectService;


@Service
public class SubjectServiceImpl implements SubjectService {
	@Autowired
	SubjectMapper subjectMapper;
	@Autowired
	StudentMapper studentMapper;

	@Override
	public List<Map<String, Object>> subjectSearch(String sbj_status, String sbj_name, String teh_name) {
		List<Map<String, Object>> list = subjectMapper.subjectSearch(sbj_status,sbj_name,teh_name);
		Map<String,Object> map = studentMapper.searchStatus(GetUserName.getUserName());
		list.add(map);
		return list;
	}


	@Override
	public Map<String, String> subjectSetTopic(Subject subject) {
		Map<String, String> result = new HashMap<String, String>();
		try {
			subjectMapper.subjectInsert(subject);
			result.put("code", "200");
			return result;
		}catch (Exception e) {
			result.put("code", "500");
			return result;
		}
	}

	@Override
	public Map<String, String> subjectUpdate(Subject subject) {
		Map<String, String> result = new HashMap<>();
		try {
			subjectMapper.subjectUpdate(subject);
			result.put("code", "200");
			return result;
		}catch (Exception e) {
			result.put("code", "500");
			return result;
		}
	}

	@Override
	public Map<String, Object> subjectDelete(String sbj_id) {
		Map<String, Object> result = new HashMap<>();
		try {
			subjectMapper.subjectDelete(sbj_id);
			result.put("code", "200");
			return result;
		}catch (Exception e) {
			result.put("code", "500");
			return result;
		}
	}

	@Override
	public int searchCount() {	
		return subjectMapper.searchCount();
	}


	@Override
	public int getUncheckSubject() {
		// TODO Auto-generated method stub
		return subjectMapper.getUncheckSubject();
	}

	@Override
	public int getCheckSubject() {
		// TODO Auto-generated method stub
		return subjectMapper.getCheckSubject();
	}

	@Override
	public int getRefuseSubject() {
		// TODO Auto-generated method stub
		return subjectMapper.getRefuseSubject();
	}

	@Override
	public List<Map<String, Object>> uncheckSubjectSearch() {
		// TODO Auto-generated method stub
		return subjectMapper.uncheckSubjectSearch();
	}

	@Override
	public List<Map<String, Object>> checkSubjectSearch() {
		// TODO Auto-generated method stub
		return subjectMapper.checkSubjectSearch();
	}


	@Override
	public List<Map<String, Object>> refuseSubjectSearch() {
		// TODO Auto-generated method stub
		return subjectMapper.refuseSubjectSearch();
	}


	@Override
	public Map<String, Object> getSubDetail(String sub_id) {
		// TODO Auto-generated method stub
		return subjectMapper.getSubDetail(sub_id);
	}

	@Override
	public List<Map<String, Object>> querySubject1(String teachername, String teacherid, String subname) {
		// TODO Auto-generated method stub
		return subjectMapper.querySubject1(teachername,teacherid,subname);
	}
	
	@Override
	public List<Map<String, Object>> querySubject2(String teachername, String teacherid, String subname) {
		// TODO Auto-generated method stub
		return subjectMapper.querySubject2(teachername,teacherid,subname);
	}
	
	@Override
	public List<Map<String, Object>> querySubject3(String teachername, String teacherid, String subname) {
		// TODO Auto-generated method stub
		return subjectMapper.querySubject3(teachername,teacherid,subname);
	}
}
